<template>
    <el-menu
        default-active="/docPage"
        class="el-menu-vertical-demo"
        router
    >
      <el-avatar id="logo" shape="squre" :size="78" :src="logo" style="background-color: #ffffff"></el-avatar>
      <el-menu-item index="/docPage">
        <i class="el-icon-notebook-2"></i>
        <span slot="title">智库DOC管理</span>
      </el-menu-item>
      <el-menu-item index="/userPage" v-if="user.userRole=='admin'">
        <i class="el-icon-user"></i>
        <span slot="title">用户管理</span>
      </el-menu-item>
      <el-menu-item index="/docDirectPage">
        <i class="el-icon-chat-square"></i>
        <span slot="title">分类管理</span>
      </el-menu-item>
      <el-menu-item index="/loginfo" v-if="user.userRole=='admin'">
        <i class="el-icon-notebook-1"></i>
        <span slot="title">日志查看</span>
      </el-menu-item>
<!--      <el-menu-item index="/userSetting">-->
<!--        <i class="el-icon-setting"></i>-->
<!--        <span slot="title">账号设置</span>-->
<!--      </el-menu-item>-->
      <el-menu-item index="/settingPage" v-if="user.userRole=='admin'">
        <i class="el-icon-set-up"></i>
        <span slot="title">站点设置</span>
      </el-menu-item>
      <el-menu-item @click="logout()">
        <i class="el-icon-switch-button"></i>
        <span slot="title">用户退出</span>
      </el-menu-item>
      <el-menu-item index="/apidoc" v-if="user.userRole=='admin'">
        <i class="el-icon-set-up"></i>
        <span slot="title">前台对接API文档</span>
      </el-menu-item>
    </el-menu>
</template>

<script>



import {userApi} from "@/api/user";
import {commonApi} from "@/api/commonApi";

export default {
  name: "manggerLefter",
  data(){
    return{
      logo:null,
      user:JSON.parse(sessionStorage.getItem("loginStatus"))
    }
  },
  methods:{
    logout(){
      this.axios.post(userApi.sysLogout)
        .then(res=>{
          if(!res.data.code){
            this.$message.success(res.data.message);
            sessionStorage.removeItem('loginStatus')
          this.$router.push('/login');
          }
        })

    }
  },
  mounted() {
    this.axios.get(commonApi.getAttributeByCommon+'siteLogo')
        .then(res=>{
          if (!res.data.code){
            this.logo=res.data.data
          }
        })
  }
}
</script>

<style scoped>
.el-menu-vertical-demo{
  height: 100vh;
  text-align: center;
}
#logo{
  margin-top: 50px;
}
</style>